package com.huanri.test;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Collections;
import java.util.Date;
import java.util.List;

import junit.framework.TestCase;
import sun.misc.BASE64Decoder;
import sun.misc.BASE64Encoder;


/**
 * @author Nemo
 * @date 2012-8-17 at MyCode
 */
public class Client extends TestCase {

	public void test1(){
		String s = System.getProperty("user.dir");
		String pn = s.substring(s.lastIndexOf('\\')+1,s.length()); //取当前工程名
		String ss = System.getProperty("JAVA_HOME");
		System.out.println(s);
		System.out.println(pn);
		System.out.println(ss);
	}
	public void test2(){
		System.setProperty("catalina.home", System.getProperty("user.dir"));
		String s = System.getProperty("catalina.home", System.getProperty("user.dir"));
		System.out.println(s);
	}	
	public void test3(){
		String s = "s";
		BASE64Encoder encode = new BASE64Encoder();
		BASE64Decoder decode = new BASE64Decoder();
		String ss = encode.encode(s.getBytes());
		System.out.println(ss);
		try {
			System.out.println(decode.decodeBuffer(s));
			System.out.println(decode.decodeBuffer(ss));
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	public void test4(){
		File file = new File("E:\\1234.sql");
		String s = "select * from rcn_result;2222222222222";
		try {
			BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(file));
			bos.write(s.getBytes());
			bos.flush();
//			FileWriter fw = new FileWriter(file);
//			fw.write(s);
//			fw.flush();
//			FileOutputStream out = new FileOutputStream(file);			
//			out.write("create table 123 values ".getBytes());			
		}  catch (FileNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	public void test5(){
		File file = new File("e:\\a");
		if(!file.exists()){
			file.mkdir();
		}
		File file1 = new File("e:\\b\\");
		File file2 = new File(file1.getAbsoluteFile()+"1.txt");
	}
	public void test6(){
		Date date = new Date();
		String temp = DateFormat.getDateInstance().format(date);
		String s = new SimpleDateFormat("yyyy-MM-dd").format(date);
		System.out.println(date.toString());
		System.out.println(temp);
		System.out.println(s);
	}
	public void test7(){

	}
}
